package com.alks.function.controller.procurement;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.procurement.*;
import com.alks.function.service.procurement.PackagOtherOrderingOperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@ApiRestController("/PackagOtherOrderingOperation")
@Slf4j
@Api(value = "包材其他订购", tags = {"采购部-包材其他订购作业"})
@RoleCheck(prgIds = {"150109"})
public class PackagOtherOrderingOperationController {

    @Autowired
    private PackagOtherOrderingOperationService pOtherOrderingOperationService;



    /*待定购*/
    @WebLogger
    @PostMapping("/getNotOrderMaterialList")
    @ApiOperation(value = "待订购明细-查询",tags = "采购部-包材其他订购作业")
    public ResponseInfo getNotOrderMaterialList(@RequestBody NotOrderMaterialRequest request){
        return pOtherOrderingOperationService.getNotOrderMaterialList(request);
    }

    @WebLogger
    @PostMapping("/updateBatchNotOrderMaterial")
    @ApiOperation(value = "待订购明细:编辑",tags = "采购部-包材其他订购作业")
    public ResponseInfo updateBatchNotOrderMaterial(@RequestBody List<PcPackDetailRequest> request){
        return pOtherOrderingOperationService.updateBatchNotOrderMaterial(request);
    }

    @WebLogger
    @PostMapping("/deleteNotOrderMaterial")
    @ApiOperation(value = "待订购明细:删除",tags = "采购部-包材其他订购作业")
    public ResponseInfo deleteNotOrderMaterial(@RequestBody List<Integer> ids){
        return pOtherOrderingOperationService.deleteNotOrderMaterial(ids);
    }

    /*已订购*/
    @WebLogger
    @PostMapping("/getOrderedDetailsList")
    @ApiOperation(value = "已订购明细-查询",tags = "采购部-包材其他订购作业")
    public ResponseInfo getOrderedDetailsList(@RequestBody NotOrderMaterialRequest request){
        return pOtherOrderingOperationService.getOrderedDetailsList(request);
    }

    @WebLogger
    @PostMapping("/updateOrderedRemark")
    @ApiOperation(value = "已订购明细-批量更新（备注+请购类型）",tags = "采购部-包材其他订购作业")
    public ResponseInfo updateOrderedRemark(@RequestBody List<PcPackDetailRequest> request){
        return pOtherOrderingOperationService.updateOrderedRemark(request);
    }

    @WebLogger
    @PostMapping("/updateReqDateAndUPrice")
    @ApiOperation(value = "修改需求日期/单价",tags = "采购部-包材其他订购作业")
    public ResponseInfo updateReqDateAndUPrice(@RequestBody NewPcPackDetailRequest request){
        return pOtherOrderingOperationService.updateReqDateAndUPrice(request);
    }

    @WebLogger
    @PostMapping("/cancelOrderedDetails")
    @ApiOperation(value = "订购单取消",tags = "采购部-包材其他订购作业")
    public ResponseInfo cancelOrderedDetails(@RequestParam String slipNo){
        return pOtherOrderingOperationService.cancelOrderedDetails(slipNo);
    }
    @WebLogger
    @PostMapping("/makePurchaseOrder")
    @ApiOperation(value = "生成订购单",tags = "采购部-包材其他订购作业")
    public ResponseInfo makePurchaseOrder(@RequestBody BatchProcessNotOrderMaterialRequest request){
        return pOtherOrderingOperationService.makePurchaseOrder(request);
    }

    @WebLogger
    @PostMapping("/selectMaterial")
    @ApiOperation(value = "双击料号选择材料批量选择/手动添加待定购明细",tags = "采购部-包材其他订购作业")
    public ResponseInfo selectMaterial(@RequestBody List<SdMaterialRequest> request){
        return pOtherOrderingOperationService.selectMaterial(request);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrder")
    @ApiOperation(value = "导出订购单",tags = "采购部-包材其他订购作业")
    public void exportPurchaseOrder(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        pOtherOrderingOperationService.exportPurchaseOrder(request,response);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrderByLongitudinal")
    @ApiOperation(value = "导出订购单(分段/纵)",tags = "采购部-包材其他订购作业")
    public void exportPurchaseOrderByLongitudinal(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        pOtherOrderingOperationService.exportPurchaseOrderByLongitudinal(request,response);
    }

    @WebLogger
    @PostMapping("/exportPurchaseOrderByTransverse")
    @ApiOperation(value = "导出订购单(分段/横)",tags = "采购部-包材其他订购作业")
    public void exportPurchaseOrderByTransverse(@RequestBody NotOrderMaterialRequest request, HttpServletResponse response){
        pOtherOrderingOperationService.exportPurchaseOrderByTransverse(request,response);
    }


}
